﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using SYH.Utils;
using System.Data;
using SYH.Enum;

namespace admin.syh876.com.Controllers
{
    public class ProMgrController : Controller
    {
        #region 产品行业分类管理

        //产品行业分类
        public ActionResult IndustryList()
        {
            //string sqlWhere = " Status=0";
            //// DataTable Product_TypeDt = SYH.Product.BLL.Industry_Info.GetList(sqlWhere).Tables[0];
            //PagerSource ps = new PagerSource("p", 15);
            //int pageCount = 0;
            //int recordCount = 0;
            //DataTable Product_TypeDt = SYH.Product.BLL.Industry_Info.GetPageData(ps.PageSize, ps.CustomPage, sqlWhere.ToString(), out pageCount, out recordCount);

            //return View(Product_TypeDt);
            return View();
        }

        //行业编辑
        public ActionResult IndustryDetail(int id = 0)
        {
            //Industry_Info model = SYH.Product.BLL.Industry_Info.GetModel(id);
            //if (model == null)
            //{
            //    model = new Industry_Info();

            //}
            //#region 分类信息
            //string sqlWhere = " Status=0";
            //DataTable Product_IndustryDt = SYH.Product.BLL.Industry_Info.GetList(sqlWhere).Tables[0];
            //ViewBag.Product_IndustryDt = Product_IndustryDt;
            //#endregion
            //return View(model);
            return View();
        }
        //保存
        public ActionResult IndustrySave()//Industry_Info model
        {
            //if (model.Id > 0)
            //{
            //    if (SYH.Product.BLL.Industry_Info.Update(model))
            //    {
            //        return Content("1");
            //    }
            //    else
            //    {
            //        return Content("0");
            //    }
            //}
            //else
            //{
            //    if (SYH.Product.BLL.Industry_Info.Add(model) > 0)
            //    {
            //        return Content("1");
            //    }
            //    else
            //    {
            //        return Content("0");
            //    }
            //}
            return Content("0");
        }

        //删除
        public ActionResult IndustryDelete(int id = 0)
        {

            //string strWhere = " id=" + id;
            //if (SYH.Product.BLL.Industry_Info.UpdateOneField("Status", "-1", strWhere, false))
            //{
            //    return Content("1");
            //}
            //else
            //{
            //    return Content("0");
            //}
            return Content("0");
        }
        #endregion

        #region 产品审核
        //产品列表信息
        //状态 -1关闭(删除) 0待审 1通过 - 2拒绝
        public ActionResult ProductList(int Status = 0, string SearchKey="", int TypeId = 0)
        {
            //ViewBag.Status = Status;
            //#region 分类信息
            //string sqlWhere = " Status=0";
            //DataTable Product_IndustryDt = SYH.Product.BLL.Industry_Info.GetList(sqlWhere).Tables[0];
            //ViewBag.Product_IndustryDt = Product_IndustryDt;
            //#endregion

            //string strSql = string.Format(" and Status={0} ", Status);

            //PagerSource ps = new PagerSource("p", 10);
            //int pageCount = 0;
            //int recordCount = 0;
            //DataTable Product_Dt = SYH.Product.BLL.Product_Info.GetPageData(ps.PageSize, ps.CustomPage, strSql.ToString(), out pageCount, out recordCount);

            //return View(Product_Dt);
            return View();
        }
        //编辑产品信息
        public ActionResult ProductDetail(int id = 0)
        {
            //SYH.Product.Model.Product_Info model = SYH.Product.BLL.Product_Info.GetModel(id);
            //if (model == null)
            //{
            //    model = new SYH.Product.Model.Product_Info();
            //}
            //ViewBag.Introduction = SYH.Product.BLL.Product_Info.GetProductIntroduction(id);
            //return View(model);
            return View();
        }
        //保存
        //[HttpPost]
        //[ValidateInput(false)]
        //public ActionResult ProductSave(Product_Info model)
        //{
        //    model = Common.ModelHelper.FillModel<Product_Info>(model);
        //    if (model.Id > 0)
        //    {
        //        if (SYH.Product.BLL.Product_Info.Update(model))
        //        {
        //            return Content("1");
        //        }
        //        else
        //        {
        //            return Content("0");
        //        }

        //    }
        //    else
        //    {
        //        if (SYH.Product.BLL.Product_Info.Add(model) > 0)
        //        {
        //            return Content("1");
        //        }
        //        else
        //        {
        //            return Content("0");
        //        }
        //    }

        //}

        //[HttpPost]
        //public ActionResult ProductDelete(int id = 0)
        //{
        //    string field = "Status";
        //    string value = ((int)ProStatus.拒绝).ToString();
        //    string strWhere = " Id=" + id;
        //    if (SYH.Product.BLL.Product_Info.UpdateOneField(field, value, strWhere, false))
        //    {
        //        return Content("1");
        //    }
        //    else
        //    {
        //        return Content("0");
        //    }
        //}
        //#endregion


        [HttpPost]
        public ActionResult ProInfoOper(string action = "", int id = 0, int sort = 0)
        {
            //string field = "Status"; //要修改的字段名
            //string value = string.Empty;
            //string strWhere = " Id=" + id;

            ////判断操作类型
            //switch (action)
            //{
            //    case "delete": value = ((int)ProStatus.删除).ToString();
            //        break;
            //    case "pass": value = ((int)ProStatus.通过).ToString();
            //        break;
            //    case "unpass": value = ((int)ProStatus.拒绝).ToString();
            //        break;
            //    //case "sort": value = sort.ToString();
            //    //    field = "Sort";
            //    //    break;
            //    default: value = ((int)ProStatus.待审).ToString();
            //        break;
            //}

            //if (SYH.Product.BLL.Product_Info.UpdateOneField(field, value, strWhere, false))
            //{
            //    return Content("1");
            //}
            //else
            //{
            //    return Content("0");
            //}
            return Content("0");
        }
        #endregion
    }
}
